package com.example.wechattakeaway.controller;

import com.example.wechattakeaway.utils.FileUpload;
import com.example.wechattakeaway.utils.ResultVOUtil;
import com.example.wechattakeaway.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@RestController
@RequestMapping("/UploadImgController")
@Api(tags = "图片上传模块")
public class UploadImgController {

    @ApiOperation(value = "上传图片并返回url路径信息",notes = "商家web端")
    @PostMapping("/UploadImg")
    public ResultVO UploadImg(@RequestParam("file") MultipartFile file){
        String imgUrl= FileUpload.UploadPicture(file);
        return ResultVOUtil.success(imgUrl);
    }

}
